<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<link rel="stylesheet" type="text/css" href="estilo.css">

</head>
<body>
<?php

$num=$_GET['num'];


/*
// connect to gmail 
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'webg32@gmail.com';
$password = 'andatza32';
*/
require('conexionbd.php');

require('idusuario.php');

// cogo mediante get el usuario que a iniciado sesion 


$datos=mysql_query("SELECT * FROM correo WHERE id_usuario='$id'", $con);

	if($row = mysql_fetch_array($datos)){
	
		$mail=$row['email'];
		$pwd=$row['contrasena'];
			
	}	



	$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';


	$username = $mail;
	$password = $pwd;




/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());

/* grab emails */
$emails = imap_search($inbox,'ALL');

/* if emails are returned, cycle through each... */
if($emails) {
  
  /* begin output var */
  $output = '';
  
  /* put the newest emails on top */
  rsort($emails);
  
  ?>
  <div id="tit">
		<p>Mensajes</p>
		<img src="imagenes/cerrar.png" onclick="getOcultarCuadrado(3);" />
	</div>
	<div id="cont">
<?php
  
  /* for every email... */
  //foreach($emails as $email_number) {
    
    /* get information specific to this email */
    //$overview = imap_fetch_overview($inbox,$num,0);
    $message = imap_fetchbody($inbox,$num,2);
    
   
	
    /* output the email body */
    $output.= '<div class="bodyy">'.$message. '</div>';
	
  //}
  
  echo $output;
} 

/* close the connection */
imap_close($inbox);


?>

</body>
</html>